#include "ConstantFunction.h"
#include "../Backpropagation/BackpropagationSynapse.h"
#include "../Backpropagation/ActivationNeuron.h"
#include "../Helper.h"

using namespace NeuralPlusPlus::Core;

void NeuralPlusPlus::Core::Initializers::ConstantFunction::Initialize( Connector *connector )
	{
	Helper::ValidateNotNull(connector, "connector");
	int synapsesSize = connector->SynapsesLength;
	for(int j=0;j<synapsesSize;j++)
		{
		ISynapse *synapse = &(*connector->Synapses)[j];
		synapse->Weight = Constant;
		}
	}

void NeuralPlusPlus::Core::Initializers::ConstantFunction::Initialize( Layer *activationLayer )
	{
	Helper::ValidateNotNull(activationLayer, "layer");
	int neuronLength = activationLayer->NeuronsLength;
	for (int i=0;i<neuronLength;i++)
		{
		((ActivationNeuron*)(*activationLayer)[i])->Bias = Constant;
		}
	}

NeuralPlusPlus::Core::Initializers::ConstantFunction::ConstantFunction( double constant )
	{
	this->Constant = constant;
	}